package tiaozhuan;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
@WebServlet("/s3")
public class Servlet3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BufferedReader reader=req.getReader();
        String line;
        while ((line=reader.readLine())!=null){
            String []arr=line.split("&");
            String username=arr[0].split("=")[1];
            String password=arr[1].split("=")[1];
            if ("admin".equals(username)&&"admin".equals(password)) {
                req.getRequestDispatcher("/success3").forward(req,resp);
                System.out.println(line);
            }
            else {
                req.getRequestDispatcher("/fail3").forward(req,resp);
            }

        }


    }
}
